package com.speedchina.permission.domain.sys.entity;

import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.HeadStyle;
import com.baomidou.mybatisplus.annotation.TableName;
import com.speedchina.common.download.convert.GenderConvert;
import com.speedchina.common.download.convert.ManagerStatusConvert;
import com.speedchina.common.upload.annotation.Unique;
import com.speedchina.framework.base.TEntity;
import com.speedchina.framework.validator.group.AddGroup;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.apache.poi.ss.usermodel.FillPatternType;

import org.hibernate.validator.constraints.Email;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.NotBlank;

import javax.validation.constraints.Pattern;


/**
 * 系统-用户表 实体类
 * @author hank
 * @date 2021-04-08 13:59:05
 */
@Data
@TableName("t_sys_user")
@HeadStyle(fillPatternType = FillPatternType.SOLID_FOREGROUND, fillForegroundColor = 10)
public class User extends TEntity<User> {
    /**
     * ID主键
     */
    @ApiModelProperty(value = "ID主键")
    private String id;
    /**
     * 昵称、真实姓名
     */
    @ApiModelProperty(value = "昵称、真实姓名")
    @ExcelProperty(value = "姓名",index = 0)
    @NotBlank(groups = AddGroup.class,message = "姓名不能为空")
    @Length(max = 255,message = "姓名字符长度过长",groups = AddGroup.class)
    private String nickname;
    /**
     * 用户名 / 登录名
     */
    @ApiModelProperty(value = "用户名/登录名")
    @ExcelProperty(value = "登录名",index = 1)
    @NotBlank(groups = AddGroup.class,message = "登录名不能为空")
    @Unique
    @Length(max = 50,message = "登录名字符长度过长",groups = AddGroup.class)
    private String username;
    /**
     * 密码
     */
    @ApiModelProperty(value = "密码")
    private String password;
    /**
     * 盐值
     */
    @ApiModelProperty(value = "盐值")
    private String salt;
    /**
     * 邮箱地址
     */
    @ApiModelProperty(value = "邮箱地址")
    @ExcelProperty(value = "邮箱地址",index = 3)
    @Email(groups = AddGroup.class,message = "邮箱格式错误")
    @Length(max = 128,message = "邮箱字符长度过长",groups = AddGroup.class)
    private String email;
    /**
     * 手机号(预留位数)
     */
    @ApiModelProperty(value = "手机号(预留位数)")
    @ExcelProperty(value = "手机号",index = 2)
    @NotBlank(groups = AddGroup.class,message = "手机号不能为空")
    @Pattern(groups = AddGroup.class,regexp = "^1[3|4|5|7|8][0-9]{9}$",message = "手机号错误")
    @Length(max = 20,message = "手机号字符长度过长",groups = AddGroup.class)
    private String mobile;
    /**
     * 性别: UNKNOW、MALE、FEMALE
     */
    @ApiModelProperty(value = "性别: UNKNOW、MALE、FEMALE")
    @ExcelProperty(value = "性别",converter = GenderConvert.class,index = 4)
    @NotBlank(groups = AddGroup.class,message = "性别不能为空")
    @Length(max = 10,message = "性别字符长度过长",groups = AddGroup.class)
    private String sex;
    /**
     * 当前状态（0 禁用，1可用）
     */
    @ApiModelProperty(value = "当前状态（0 禁用，1可用）")
    @NotBlank(groups = AddGroup.class,message = "状态不能为空")
    @ExcelProperty(value = "状态",converter = ManagerStatusConvert.class,index = 10)
    @Length(max = 32,message = "状态字符长度过长")
    private String status;


    public User(){
    }
    public User(String userId,String username){
        this.id=userId;
        this.username=username;
    }
    public User(String userId,String username,String password){
        this.id=userId;
        this.username=username;
        this.password=password;
    }
}
